Add BooleanArgumentFlag rule and related configurations#91
Merged
Conversation
Owner
Orrison
commented
Nov 1, 2025
- Implement BooleanArgumentFlag rule to detect boolean parameters indicating multiple responsibilities.
- Introduce configuration options for ignored classes and ignore patterns.
- Update README with new rule documentation.
- Add tests for various scenarios including ignored classes and patterns.
- Implement BooleanArgumentFlag rule to detect boolean parameters indicating multiple responsibilities. - Introduce configuration options for ignored classes and ignore patterns. - Update README with new rule documentation. - Add tests for various scenarios including ignored classes and patterns. Signed-off-by: Kevin Ullyott <ullyott.kevin@gmail.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new PHPStan rule BooleanArgumentFlag that detects boolean parameters in functions, methods, and closures, which may indicate a violation of the Single Responsibility Principle. The rule includes configurable options to ignore specific classes or methods matching a pattern.
Key changes:
- New rule implementation with support for class methods, functions, and closures
- Configuration options for ignored classes and method name patterns
- Comprehensive test coverage including default, ignored classes, ignore pattern, and combined configuration scenarios
- Complete documentation with usage examples
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Rules/BooleanArgumentFlag/BooleanArgumentFlagRule.php | Main rule implementation that detects boolean parameters in function-like constructs |
| src/Rules/BooleanArgumentFlag/Config.php | Configuration class for ignored classes and ignore patterns |
| config/extension.neon | Schema definition and service registration for the new rule |
| docs/BooleanArgumentFlag.md | Complete documentation with configuration options and examples |
| README.md | Added rule entry to the rules table |
| tests/Rules/BooleanArgumentFlag/DefaultOptionsTest.php | Tests for default behavior |
| tests/Rules/BooleanArgumentFlag/IgnoredInClassesTest.php | Tests for ignored classes configuration |
| tests/Rules/BooleanArgumentFlag/IgnorePatternTest.php | Tests for pattern-based ignoring |
| tests/Rules/BooleanArgumentFlag/AllOptionsTrueTest.php | Tests for combined configuration options |
| tests/Rules/BooleanArgumentFlag/Fixture/*.php | Test fixture files with various boolean parameter scenarios |
| tests/Rules/BooleanArgumentFlag/config/*.neon | Test configuration files for different scenarios |
…curacy Signed-off-by: Kevin Ullyott <ullyott.kevin@gmail.com>
…and accuracy in error message line numbers Signed-off-by: Kevin Ullyott <ullyott.kevin@gmail.com>
… include invalid regex configuration Signed-off-by: Kevin Ullyott <ullyott.kevin@gmail.com>
…entFlag documentation Signed-off-by: Kevin Ullyott <ullyott.kevin@gmail.com>
Signed-off-by: Kevin Ullyott <ullyott.kevin@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ment_flag schema Signed-off-by: Kevin Ullyott <ullyott.kevin@gmail.com>
…or preg_last_error Signed-off-by: Kevin Ullyott <ullyott.kevin@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.